#include <unistd.h>
#include <pthread.h>
#include <stdio.h>

class Test
{
public:
    Test()
    {
        static int i = 0;
        printf("i(%d)\n", ++i);
        sleep(1);
    }
};

void * test(void *arg)
{
    static Test *a = new Test();
    printf("a[0x%08x]\n", a);
    return NULL;
}

int main(int argc, char *argv[])
{
    const int MAX = 100;
    pthread_t thread[MAX] = {0};
    int i = 0;

    argc = argc;
    argv = argv;

    for (i=0; i<MAX; ++i) {
        pthread_create(&thread[i], NULL, test, NULL);
    }

    for (i=0; i<MAX; ++i) {
        pthread_join(thread[i], NULL);
    }
    return 0;
}
